package cn.dongqihong.produceconsumption;

/**
 * Created by DongQihong on 2016/12/15.
 */
public class Restaurant {
    public static void main(String[] args) {
        Basket basket = new Basket();
        Cook cook1 = new Cook("师傅A", basket);
        Cook cook2 = new Cook("师傅B", basket);
        Cook cook3 = new Cook("师傅C", basket);

        Dinner dinner1 = new Dinner("食客1", basket);
        Dinner dinner2 = new Dinner("食客2", basket);
        Dinner dinner3 = new Dinner("食客3", basket);
        Dinner dinner4 = new Dinner("食客4", basket);

        new Thread(dinner1).start();
        new Thread(dinner2).start();
        new Thread(dinner3).start();
        new Thread(dinner4).start();

//        try {
//            Thread.sleep(10000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

        cook1.start();
        cook2.start();
        cook3.start();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        dinner1.stopEat();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        dinner1.stopEat();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        dinner2.stopEat();
    }
}
